package controllers;

 
import initializers.ChatSystem;  
import java.util.*;
import java.util.ArrayList;
import models.*;
import views.ChatGui; 
import views.ChatNi; 

// <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
// #[regen=yes,id=DCE.764F2FB3-09A2-9AE6-F5AB-36C49EE3B8BE]
// </editor-fold> 
public class ChatController {

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.E91EF295-679A-E24D-694F-AF3933981E9A]
    // </editor-fold> 
    private ChatSystem chatSystem;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.C8356A89-4190-9901-EBC3-A1C79F107408]
    // </editor-fold> 
    private ChatGui gui;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.06E30FDE-C416-D86B-E2F2-128E498B942D]
    // </editor-fold> 
    private ChatNi ni;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.25F52EAB-857F-F139-0BB9-6E6D978F09B4]
    // </editor-fold> 
    private ListContacts lContacts;

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.D1FCA968-E17F-D135-9D6F-2AB31AFF189F]
    // </editor-fold> 
    private Contact lUser;

    public ChatController(){
        lContacts = new ListContacts();
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.FC062266-822A-9D6A-A227-618BFCDF9FF3]
    // </editor-fold> 
    public void performConnect (String nickname) {
        // the Connect button clicked
        setLUser(new Contact(nickname, "127.0.0.1"));
        // broadcasting UDP Hello Message on the network...
        //ni.sendHello(null, true);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A03060A9-C356-7655-1C0D-FD76A052C4B7]
    // </editor-fold> 
    public void newContact (Contact rContact, Boolean resplyRequired) {
        // received a Hello message
        getLContacts().addContact(rContact);
        gui.addContact(rContact.getNickname());
        // replying if necessary
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A15B42D3-F47B-3517-D2AB-D383DB1CABCD]
    // </editor-fold> 
    public void performSendMsg (String m, ArrayList<Integer> iContact) {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A6AC1C52-C8D3-0105-72F5-6BB4F196896A]
    // </editor-fold> 
    public void performDisconnect () {
        setLUser(null);
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.755F5A44-8420-DD45-068B-EE049DEE3CE3]
    // </editor-fold> 
    public void performSendFile (String fname, ArrayList<Integer> iContact) {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.2F581B72-FAD3-F6CA-094E-AEAF69277352]
    // </editor-fold> 
    public void removeContact (Contact contact) {
        getLContacts().removeContact(contact);
        gui.removeContact(contact.getNickname());
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.6048273D-648D-37C5-5CEC-F01FA14ADB49]
    // </editor-fold> 
    public void newMessage (String m, Contact rCont) {
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.9627D5BD-1932-DAC2-9A8C-CBA51FEC0C36]
    // </editor-fold> 
    public void newFile (String f, Contact rCont) {
    }

    /**
     *  @param chatSystem the chatSystem to set
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.D1E9199B-6EA3-4454-14A8-34DCEAFACE38]
    // </editor-fold> 
    public void setChatSystem (ChatSystem cs) {
        chatSystem = cs;
    }

    /**
     *  @param gui the gui to set
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.37563F9E-B518-7169-9EFB-D8D04CF836A7]
    // </editor-fold> 
    public void setGui (ChatGui g) {
        gui = g;
    }

    /**
     *  @param ni the ni to set
     */
    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.A237C7E7-327D-3501-F93D-757A4E26D17E]
    // </editor-fold> 
    public void setNi (ChatNi n) {
        ni = n;
    }

    public void setLUser (Contact contact){
        lUser = contact;
    }

    public Contact getLUser (){
        return lUser;
    }

    public void setLContacts(ListContacts list){
        lContacts = list;
    }

    public ListContacts getLContacts(){
        return lContacts;
    }

    // <editor-fold defaultstate="collapsed" desc=" UML Marker "> 
    // #[regen=yes,id=DCE.9E862619-9BDC-8730-E7FE-F80CFA36313B]
    // </editor-fold> 
    private ArrayList<Contact> compDestCont (ArrayList<Integer> iContact) {
        return null;
    }

}

